home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 May: Tool Chest / Developer CD Series Tool Chest (Apple Computer)(May 1999).iso / Tool Chest / Development Kits / MPW etc / Miscellaneous / MPW p2c / p2cLibraries / Builtins.c next >
Encoding:
C/C++ Source or Header  |  1997-01-29  |  1.3 KB  |  53 lines  |  [TEXT/MPS ]

  1. /*---------------------------------------------------------------------------*
  2.  |                                                                           |
  3.  |                 <<< Builtins.c - p2c builtin routines >>>                 |
  4.  |                                                                           |
  5.  |                    Copyright Apple Computer, Inc. 1994                      |
  6.  |                            All rights reserved.                           |
  7.  |                                                                           |
  8.  *---------------------------------------------------------------------------*/
  9.  
  10. /* 
  11.  
  12. This file defines the following routines:
  13.  
  14. InitArgCArgV(theArgC, theArgV, theEnv, cvtToPString)    - initialize global argv vector
  15.  
  16. PB_Power(base, n)    - raise base to the n-th power
  17.     
  18. */
  19.  
  20. #include "Builtins.h"
  21. #include <strings.h>
  22.  
  23. int ArgC;
  24. char **ArgV;
  25. char **Env;
  26.  
  27. void InitArgCArgV(int theArgC, char **theArgV, char **theEnv, Boolean cvtToPString)
  28. {
  29.     int i;
  30.     
  31.     ArgC = theArgC;
  32.     ArgV = theArgV;
  33.     Env = theEnv;
  34.     
  35.     if (cvtToPString) {            /* change to pStrings if needed    */
  36.         for (i = 0; i < theArgC; ++i)    
  37.             c2pstr(theArgV[i]);
  38.         if (theEnv)
  39.             for (i = 0; theEnv[i]; ++i)    
  40.                 c2pstr(theEnv[i]);
  41.     }
  42. }
  43.  
  44. int PB_Power(int base, int n)
  45. {
  46.     int i, p = 1;
  47.     
  48.     for (i = 1; 1 <= n; ++i)
  49.         p = p * base;
  50.     
  51.     return p;
  52. }
  53.